#include <iostream>
using namespace std;

//a>0,b>0
long long GreatestCommonDivisor(long long a,long long b){
	if( a>b ){
		long long temp = a;
		a = b;
		b = temp;
	}
	while( b%a ){
		long long temp = b;
		b = a;
		a = temp%a;
	}
	return a;
}
struct fraction{
	long long a,b;
	fraction(long long a_,long long b_):a(a_),b(b_){
	}
	fraction(){ }
	fraction operator + (const fraction &f){
		fraction tmp;
		tmp.a = this->a*f.b + f.a*this->b;
		tmp.b = this->b*f.b;
		return tmp;
	}
	fraction operator -(const fraction &f){
		fraction tmp;
		tmp.a = this->a*f.b - f.a*this->b;
		tmp.b = this->b*f.b;
		return tmp;
	}
	fraction operator *(const fraction &f){
		fraction tmp;
		tmp.a = this->a * f.a;
		tmp.b = this->b * f.b;
		return tmp;
	}
	fraction operator /(const fraction &f){
		if( f.a==0 ) return fraction(0,0);
		else{
			fraction tmp;
			tmp.a = this->a * f.b ;
			tmp.b = this->b * f.a;
			return tmp;
		}
	}
	void showSimple() const {
		if( this->b==0 ) cout<<"Inf";
		else{
			if( this->a==0 ){
				cout << 0;
			}else{
				if( (this->a>0 && this->b>0) || (this->a<0 && this->b<0)){
					long long d = this->a/this->b;
					if( this->a%this->b ){
						long long c = GreatestCommonDivisor(this->a%this->b,this->b);
						if( d ) cout<<d<<" ";
						cout<<this->a%this->b/c<<"/"<<this->b/c;
					}else{
						cout<<d;						
					}
				}else{
					cout<<"(-";
					long long aa = this->a>0? this->a:-this->a,bb = this->b>0?this->b:-this->b;
					long long d = aa/bb; 
					if( aa%bb ){
						long long c = GreatestCommonDivisor(aa%bb,bb);
						if( d ) cout<<d<<" ";
						cout<<aa%bb/c<<"/"<<bb/c<<")";
					}else{
						cout<<d<<")";
					}
				}
			}
		}
	}
};
ostream& operator <<(ostream &o,const fraction &f){
	f.showSimple();
	return o;
}
int main(){
	cout << GreatestCommonDivisor(6,12) << endl;
	freopen("in.txt","r",stdin);
	long long a,b,c,d;
	scanf("%lld/%lld %lld/%lld",&a,&b,&c,&d);
	fraction f1 = fraction(a,b),f2 = fraction(c,d);
	cout<<f1<<" + "<< f2 <<" = "<<f1+f2<<endl;
	cout<<f1<<" - "<< f2 <<" = "<<f1-f2<<endl;
	cout<<f1<<" * "<< f2 <<" = "<<f1*f2<<endl;
	cout<<f1<<" / "<< f2 <<" = "<<f1/f2<<endl;
	return 0;
}
